#include "interface.h"

Interface::Interface(){
	for (int i=0; i<MAX_SCREEN_COUNT; i++){
		screens[i]=NULL;
	}
	python=new Python(this);
};
Interface::~Interface(){
	for(int i=0; i<MAX_SCREEN_COUNT; i++){
		if (screens[i]!=NULL)
			switch (screens[i]->type){
				case SCR_:
					delete screens[i]; break;
				case SCR_CONSOLE:
					delete (Screen_console*) screens[i]; break;
			}
	}
};
bool Interface::add_screen(Screen* screen){
	for(int i=0; i<MAX_SCREEN_COUNT; i++){
		if (screens[i]==NULL){
			screens[i]=screen;
			return true;
		}
	}
	return false;
};
list<Command*> Interface::handle(Input* input){
	list <Command*> commands;
	return commands;
};
void Interface::handle(Action* action){
	python->process_event(action);
	if (action->type==ACT_UPDATE){
		//Action_update *a_update=(Action_update*) action;
	}
	if (action->type==ACT_ADD){
		Action_add *a_add=(Action_add*) action;
		game->add_unit(new Unit());
	}
	if (action->type==ACT_DELETE){
		//Action_delete *a_delete=(Action_delete*) action;
	}
	if (action->type==ACT_SYSTEM){
		//Action_system *a_system=(Action_system*) action;
	}
	if (action->type==ACT_EFFECT){
		//Action_effect *a_effect=(Action_effect*) action;
	}
};
void Interface::blit(){
	#ifndef NO_SCREEN
	default_screen->blit();
	#endif
};
Widget::Widget(){
/*	screen=iscreen;
	id=screen->add_widget(this);*/
};
Widget::~Widget(){
/*	screen->delete_widget(id);*/
};
void Widget::move_to(int ix, int iy){
	x=ix;
	y=iy;
};
Widget_unit::Widget_unit(){
	type=WID_UNIT;
};
Widget_unit::Widget_unit(char iname):	name(iname){
	type=WID_UNIT;
};
Widget_unit::Widget_unit(char iname, int ix, int iy):	name(iname){
	type=WID_UNIT;
	x=ix;
	y=iy;
};
Widget_building::Widget_building(){
	type=WID_BUILDING;
	x=0;
	y=0;
};
Widget_building::Widget_building(string iname): name(iname){
	type=WID_BUILDING;
	x=0;
	y=0;
};
Input_key::Input_key(int ikey, bool ictrl, bool ialt, bool ishift){
	type=INP_KEY;
	key=ikey;
	ctrl=ictrl;
	alt=ialt;
	shift=ishift;
};
Action_update::Action_update(int unit_id, long x, long y){
	type=ACT_UPDATE;
};
Action_add::Action_add(){
	type=ACT_ADD;
};